import {supplierDetails,marketDetails} from "@/common/api.js"
export default {
	methods: {
		//  微信小程序支付
		minprogramPay(payParamy,id,idx,typeId) {
			uni.requestPayment({
				provider: 'wxpay', //服务提供商
				appId:payParamy.appId,
				timeStamp: payParamy.timeStamp,
				nonceStr: payParamy.nonceStr, //随机字符串，长度为32个字符以下。
				package: payParamy.package,
				signType: payParamy.signType,
				paySign: payParamy.paySign,
				success: (res)=>{
					//支付成功的回掉 
					// console.log('支付成功')
					this.paySuccess(id,idx,typeId)
				},
				fail: function(err) {
					console.log('fail:' + JSON.stringify(err));
				}
			})
		},
		//支付成功的回掉
		paySuccess(cid,idx,typeId) {
			// 货主详情
			if(typeId == 1){
				setTimeout(()=>{
					supplierDetails({cid}).then(res=>{
						if(res.status == 0){
							console.log('huoquxiangqing')
							this.dkList[idx].isSave = res.data.isSave;
							this.dkList[idx].userMobile = res.data.userMobile
							uni.showToast({
								title: '收藏成功',
								duration: 1500
							})
						}
					})
				},1000)
				
			}
			//档口
			if(typeId == 2){
				setTimeout(()=>{
					marketDetails({cid}).then(res=>{
						if(res.status == 0){
							this.dkList[idx].isSave = res.data.isSave;
							this.dkList[idx].userMobile = res.data.userMobile
							uni.showToast({
								title: '收藏成功',
								duration: 1500
							})
						}
					})
				},1000)
				
			}
			
		}
	}
}
